package ceha.application;

import ceha.util.OkCancelDialog;
import ceha.util.OkDialog;
import java.beans.Beans;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.RollbackException;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.table.TableColumn;

public class CEHAFicheCreation extends javax.swing.JFrame {

    private final CEHAMain main;
    private String message;
//    private JTable masterTable;

    CEHAFicheCreation(CEHAMain main) {
        this.main = main;

//        this.masterTable = gdata.get;
//        this.list = data.getList();
        initComponents();
        if (!Beans.isDesignTime()) {
            entityManager.getTransaction().begin();
        }
        ficheEnable(false);


    }

    public String getMessage() {
        return message;
    }

    JInternalFrame getDonneesTablesJIF() {
        return donneesTablesCreation;
    }

    public JInternalFrame getFicheAcreerJIF() {
        return ficheAcreerJIF;
    }

    private void detruireColonne(TableColumn column) {
        column.setMinWidth(0);
        column.setMaxWidth(0);

    }

    private void ficheEnable(boolean b) {
        saveButton.setEnabled(b);
        refreshButton.setEnabled(b);
        effacerButton.setEnabled(b);
        //
        lienvignette1.setEnabled(b);
        parcourirvignette.setEnabled(b);
        sourcecombo1.setEnabled(b);
        typedocCombo1.setEnabled(b);
        titreField1.setEnabled(b);
        auteurField1.setEnabled(b);
        jDateChooser5.setEnabled(b);
        jDateChooser4.setEnabled(b);
        idcorrecteurField.setEnabled(b);
        siecleCombo1.setEnabled(b);
        resumeArea1.setEnabled(b);
        lienimageField.setEnabled(b);
        lienFichierField.setEnabled(b);
        fichierButton.setEnabled(b);
        imageButton.setEnabled(b);
        fondField1.setEnabled(b);
        jDateChooser3.setEnabled(b);
        droitsreproCombo1.setEnabled(b);
        localisationField1.setEnabled(b);
        dimensionField1.setEnabled(b);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("BDDCEHAPU").createEntityManager();
        query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT f FROM Fiche f");
        list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
        desktop = new javax.swing.JDesktopPane();
        ficheAcreerJIF = new javax.swing.JInternalFrame();
        Formulaire = new javax.swing.JPanel();
        imagefilenameLabel1 = new javax.swing.JLabel();
        sourceLabel1 = new javax.swing.JLabel();
        titreLabel1 = new javax.swing.JLabel();
        auteurLabel1 = new javax.swing.JLabel();
        dateLabel1 = new javax.swing.JLabel();
        resumeLabel1 = new javax.swing.JLabel();
        lienvignette1 = new javax.swing.JTextField();
        auteurField1 = new javax.swing.JTextField();
        lienimageField = new javax.swing.JTextField();
        parcourirvignette = new javax.swing.JButton();
        CadreVignette1 = new javax.swing.JPanel();
        vignette1 = new javax.swing.JLabel();
        sourcecombo1 = new javax.swing.JComboBox();
        typedocumentLabel2 = new javax.swing.JLabel();
        typedocCombo1 = new javax.swing.JComboBox();
        jDateChooser3 = new com.toedter.calendar.JDateChooser();
        datetexteLabel2 = new javax.swing.JLabel();
        siecleCombo1 = new javax.swing.JComboBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        resumeArea1 = new javax.swing.JTextArea();
        fichierButton = new javax.swing.JButton();
        imageButton = new javax.swing.JButton();
        historicpanel1 = new javax.swing.JPanel();
        dimensionLabel1 = new javax.swing.JLabel();
        localisationLabel1 = new javax.swing.JLabel();
        droitsreproLabel1 = new javax.swing.JLabel();
        datedonationLabel1 = new javax.swing.JLabel();
        fondLabel1 = new javax.swing.JLabel();
        fondField1 = new javax.swing.JTextField();
        localisationField1 = new javax.swing.JTextField();
        dimensionField1 = new javax.swing.JTextField();
        jDateChooser4 = new com.toedter.calendar.JDateChooser();
        droitsreproCombo1 = new javax.swing.JComboBox();
        lienfichierLabel1 = new javax.swing.JLabel();
        lienimageLabel1 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        titreField1 = new javax.swing.JTextArea();
        lienFichierField = new javax.swing.JTextField();
        Commandes = new javax.swing.JPanel();
        nouvelFicheButton = new javax.swing.JButton();
        effacerButton = new javax.swing.JButton();
        adminpanel = new javax.swing.JPanel();
        datecorrectionLabel = new javax.swing.JLabel();
        idcorrecteurLabel = new javax.swing.JLabel();
        idcorrecteurField = new javax.swing.JTextField();
        validerfiche = new javax.swing.JButton();
        jDateChooser5 = new com.toedter.calendar.JDateChooser();
        saveButton = new javax.swing.JButton();
        refreshButton = new javax.swing.JButton();
        donneesTablesCreation = new javax.swing.JInternalFrame();
        masterscrollpane = new javax.swing.JScrollPane();
        masterTable = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        raz = new javax.swing.JButton();
        idC = new javax.swing.JCheckBox();
        sourceC = new javax.swing.JCheckBox();
        typedocC = new javax.swing.JCheckBox();
        jLabel2 = new javax.swing.JLabel();
        menubar1 = new javax.swing.JMenuBar();
        mainmenu = new javax.swing.JMenu();
        quitte = new javax.swing.JMenuItem();

        setTitle("CEHA CREATION DES FICHES");

        desktop.setForeground(new java.awt.Color(255, 255, 255));
        desktop.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        ficheAcreerJIF.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        ficheAcreerJIF.setIconifiable(true);
        ficheAcreerJIF.setOpaque(true);
        ficheAcreerJIF.setVerifyInputWhenFocusTarget(false);
        ficheAcreerJIF.setVisible(true);

        Formulaire.setBackground(new java.awt.Color(51, 51, 51));

        imagefilenameLabel1.setBackground(new java.awt.Color(153, 153, 153));
        imagefilenameLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        imagefilenameLabel1.setForeground(new java.awt.Color(255, 255, 255));
        imagefilenameLabel1.setText("Vignette");

        sourceLabel1.setBackground(new java.awt.Color(153, 153, 153));
        sourceLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        sourceLabel1.setForeground(new java.awt.Color(255, 255, 255));
        sourceLabel1.setText("Source");

        titreLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        titreLabel1.setForeground(new java.awt.Color(255, 255, 255));
        titreLabel1.setText("Titre*");

        auteurLabel1.setBackground(new java.awt.Color(153, 153, 153));
        auteurLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        auteurLabel1.setForeground(new java.awt.Color(255, 255, 255));
        auteurLabel1.setText("Auteur");

        dateLabel1.setBackground(new java.awt.Color(153, 153, 153));
        dateLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        dateLabel1.setForeground(new java.awt.Color(255, 255, 255));
        dateLabel1.setText("Date ");

        resumeLabel1.setBackground(new java.awt.Color(153, 153, 153));
        resumeLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        resumeLabel1.setForeground(new java.awt.Color(255, 255, 255));
        resumeLabel1.setText("Resumé");

        lienvignette1.setFont(new java.awt.Font("Tahoma", 0, 12));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.imagefilename}"), lienvignette1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        auteurField1.setFont(new java.awt.Font("Times New Roman", 1, 14));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.auteur}"), auteurField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        lienimageField.setFont(new java.awt.Font("Tahoma", 0, 12));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.lienimage}"), lienimageField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        parcourirvignette.setFont(new java.awt.Font("Times New Roman", 3, 14));
        parcourirvignette.setText("parcourir");
        parcourirvignette.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parcourirVignetteA(evt);
            }
        });

        CadreVignette1.setBackground(new java.awt.Color(204, 204, 204));
        CadreVignette1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        vignette1.setBackground(new java.awt.Color(255, 255, 255));
        vignette1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        vignette1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/fondlogoCEHA.jpg"))); // NOI18N
        vignette1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_TOP, new java.awt.Font("Verdana", 3, 12), new java.awt.Color(0, 0, 0))); // NOI18N

        javax.swing.GroupLayout CadreVignette1Layout = new javax.swing.GroupLayout(CadreVignette1);
        CadreVignette1.setLayout(CadreVignette1Layout);
        CadreVignette1Layout.setHorizontalGroup(
            CadreVignette1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CadreVignette1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(vignette1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        CadreVignette1Layout.setVerticalGroup(
            CadreVignette1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CadreVignette1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(vignette1, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        sourcecombo1.setFont(new java.awt.Font("Verdana", 1, 12));
        sourcecombo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Original", "Copie" }));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.source}"), sourcecombo1, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        typedocumentLabel2.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        typedocumentLabel2.setForeground(new java.awt.Color(255, 255, 255));
        typedocumentLabel2.setText("Type de document");

        typedocCombo1.setFont(new java.awt.Font("Verdana", 1, 12));
        typedocCombo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Affiche", "Album thématique", "Carte postale", "Imprimé", "Journal", "Livre", "Magazine / Revue", "Manuscrit papier", "Manuscrit Vélin", "Matériel archéologique", "Numismatique", "Objet", "Photographie", "Plan", "Tableau / Gravure", "Tapuscrit", "Témoignage audio", "Témoignage vidéo", "Autres" }));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.typedocument}"), typedocCombo1, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        jDateChooser3.setDateFormatString("DD MM YYYY");
        jDateChooser3.setFont(new java.awt.Font("Verdana", 1, 12));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.date}"), jDateChooser3, org.jdesktop.beansbinding.BeanProperty.create("date"));
        bindingGroup.addBinding(binding);

        datetexteLabel2.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        datetexteLabel2.setForeground(new java.awt.Color(255, 255, 255));
        datetexteLabel2.setText("Date (autres)");

        siecleCombo1.setFont(new java.awt.Font("Verdana", 1, 12));
        siecleCombo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "XXème", "XIXème", "XVIIIème", "XVIIème" }));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.datetexte}"), siecleCombo1, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        resumeArea1.setBackground(new java.awt.Color(255, 255, 204));
        resumeArea1.setColumns(20);
        resumeArea1.setFont(new java.awt.Font("Times New Roman", 1, 12));
        resumeArea1.setLineWrap(true);
        resumeArea1.setRows(5);
        resumeArea1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        resumeArea1.setDragEnabled(true);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.resume}"), resumeArea1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jScrollPane3.setViewportView(resumeArea1);

        fichierButton.setFont(new java.awt.Font("Times New Roman", 3, 14));
        fichierButton.setText("parcourir");
        fichierButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parcourirFichierA(evt);
            }
        });

        imageButton.setFont(new java.awt.Font("Times New Roman", 3, 14));
        imageButton.setText("parcourir");
        imageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parcourirLienImageA(evt);
            }
        });

        historicpanel1.setBackground(new java.awt.Color(153, 153, 153));
        historicpanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 204, 0), 2, true), "historique du document", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 14), new java.awt.Color(255, 255, 0))); // NOI18N

        dimensionLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 14));
        dimensionLabel1.setText("Dimension");

        localisationLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 14));
        localisationLabel1.setText("Localisation");

        droitsreproLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 14));
        droitsreproLabel1.setText("Droits de reproduction");

        datedonationLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 14));
        datedonationLabel1.setText("Date de donation");

        fondLabel1.setFont(new java.awt.Font("Lucida Sans", 1, 14));
        fondLabel1.setText("Fond");

        fondField1.setFont(new java.awt.Font("Tahoma", 0, 12));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.fond}"), fondField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        localisationField1.setFont(new java.awt.Font("Tahoma", 0, 12));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.localisation}"), localisationField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        dimensionField1.setFont(new java.awt.Font("Tahoma", 0, 12));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.dimension}"), dimensionField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jDateChooser4.setDateFormatString("DD MM YYYY");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.datedonation}"), jDateChooser4, org.jdesktop.beansbinding.BeanProperty.create("date"));
        bindingGroup.addBinding(binding);

        droitsreproCombo1.setFont(new java.awt.Font("Verdana", 1, 12));
        droitsreproCombo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Fonds propres CEHA (droits réservés)", "Dépôt (avec droits accordés au CEHA)", "Fonds extérieurs (demander autorisation)", "Inconnu (ne pas publier)" }));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.droitsrepro}"), droitsreproCombo1, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout historicpanel1Layout = new javax.swing.GroupLayout(historicpanel1);
        historicpanel1.setLayout(historicpanel1Layout);
        historicpanel1Layout.setHorizontalGroup(
            historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(historicpanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(historicpanel1Layout.createSequentialGroup()
                        .addComponent(droitsreproLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(droitsreproCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(historicpanel1Layout.createSequentialGroup()
                        .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(historicpanel1Layout.createSequentialGroup()
                                .addComponent(fondLabel1)
                                .addGap(63, 63, 63)
                                .addComponent(fondField1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(datedonationLabel1))
                            .addGroup(historicpanel1Layout.createSequentialGroup()
                                .addComponent(localisationLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(localisationField1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(dimensionLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jDateChooser4, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dimensionField1, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE))))
                .addContainerGap())
        );
        historicpanel1Layout.setVerticalGroup(
            historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(historicpanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(fondLabel1)
                        .addComponent(fondField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(datedonationLabel1))
                    .addComponent(jDateChooser4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(droitsreproLabel1)
                    .addComponent(droitsreproCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(historicpanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(localisationLabel1)
                    .addComponent(localisationField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dimensionLabel1)
                    .addComponent(dimensionField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lienfichierLabel1.setBackground(new java.awt.Color(153, 153, 153));
        lienfichierLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        lienfichierLabel1.setForeground(new java.awt.Color(255, 255, 255));
        lienfichierLabel1.setText("Lien vers un fichier (PDF)");

        lienimageLabel1.setBackground(new java.awt.Color(153, 153, 153));
        lienimageLabel1.setFont(new java.awt.Font("Lucida Sans Typewriter", 1, 14));
        lienimageLabel1.setForeground(new java.awt.Color(255, 255, 255));
        lienimageLabel1.setText("Lien vers une image");

        titreField1.setBackground(new java.awt.Color(255, 255, 204));
        titreField1.setColumns(20);
        titreField1.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        titreField1.setLineWrap(true);
        titreField1.setRows(5);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.titre}"), titreField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jScrollPane4.setViewportView(titreField1);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.lienfichier}"), lienFichierField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout FormulaireLayout = new javax.swing.GroupLayout(Formulaire);
        Formulaire.setLayout(FormulaireLayout);
        FormulaireLayout.setHorizontalGroup(
            FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormulaireLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(historicpanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, FormulaireLayout.createSequentialGroup()
                            .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(FormulaireLayout.createSequentialGroup()
                                    .addComponent(typedocumentLabel2)
                                    .addGap(18, 18, 18)
                                    .addComponent(typedocCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(FormulaireLayout.createSequentialGroup()
                                    .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(titreLabel1)
                                        .addComponent(imagefilenameLabel1)
                                        .addComponent(sourceLabel1)
                                        .addComponent(auteurLabel1)
                                        .addComponent(dateLabel1))
                                    .addGap(18, 18, 18)
                                    .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                                        .addGroup(FormulaireLayout.createSequentialGroup()
                                            .addGap(13, 13, 13)
                                            .addComponent(sourcecombo1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(FormulaireLayout.createSequentialGroup()
                                            .addComponent(lienvignette1, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(parcourirvignette))
                                        .addComponent(auteurField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                        .addGroup(FormulaireLayout.createSequentialGroup()
                                            .addComponent(jDateChooser3, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(datetexteLabel2)
                                            .addGap(18, 18, 18)
                                            .addComponent(siecleCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
                                .addComponent(resumeLabel1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(CadreVignette1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(597, 597, 597))
                        .addGroup(FormulaireLayout.createSequentialGroup()
                            .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(lienimageField)
                                .addComponent(lienFichierField, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(FormulaireLayout.createSequentialGroup()
                                    .addGap(18, 18, 18)
                                    .addComponent(fichierButton)
                                    .addGap(18, 18, 18)
                                    .addComponent(lienfichierLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(FormulaireLayout.createSequentialGroup()
                                    .addGap(17, 17, 17)
                                    .addComponent(imageButton)
                                    .addGap(18, 18, 18)
                                    .addComponent(lienimageLabel1))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        FormulaireLayout.setVerticalGroup(
            FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FormulaireLayout.createSequentialGroup()
                .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FormulaireLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(imagefilenameLabel1)
                            .addComponent(lienvignette1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(parcourirvignette, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sourceLabel1)
                            .addComponent(sourcecombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(typedocumentLabel2)
                            .addComponent(typedocCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(titreLabel1)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(FormulaireLayout.createSequentialGroup()
                                .addGap(0, 0, 0)
                                .addComponent(auteurLabel1))
                            .addComponent(auteurField1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dateLabel1)
                            .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(datetexteLabel2)
                                    .addComponent(siecleCombo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jDateChooser3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(7, 7, 7)
                        .addComponent(resumeLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(FormulaireLayout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(CadreVignette1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(fichierButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lienfichierLabel1)
                        .addComponent(lienFichierField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(FormulaireLayout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(FormulaireLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lienimageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lienimageLabel1)
                            .addComponent(imageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(historicpanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
        );

        nouvelFicheButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/10.gif"))); // NOI18N
        nouvelFicheButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 0), 5, true), "Nouvelle Fiche", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 102, 51))); // NOI18N
        nouvelFicheButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nouvelFicheA(evt);
            }
        });

        effacerButton.setBackground(new java.awt.Color(255, 255, 255));
        effacerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/poubelle.jpg"))); // NOI18N
        effacerButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true), "Effacer", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        effacerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteFicheA(evt);
            }
        });

        adminpanel.setBackground(new java.awt.Color(255, 255, 255));
        adminpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 3, true), "Contrôle et validation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 14), new java.awt.Color(255, 0, 0))); // NOI18N

        datecorrectionLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
        datecorrectionLabel.setText("Date de correction");

        idcorrecteurLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
        idcorrecteurLabel.setText("Id Correcteur");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.idcorrecteur}"), idcorrecteurField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        validerfiche.setBackground(new java.awt.Color(255, 255, 255));
        validerfiche.setFont(new java.awt.Font("Times New Roman", 1, 12));
        validerfiche.setForeground(new java.awt.Color(255, 0, 0));
        validerfiche.setText("Valider la Fiche");

        jDateChooser5.setDateFormatString("DD MM YYYY");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.datecorrection}"), jDateChooser5, org.jdesktop.beansbinding.BeanProperty.create("date"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout adminpanelLayout = new javax.swing.GroupLayout(adminpanel);
        adminpanel.setLayout(adminpanelLayout);
        adminpanelLayout.setHorizontalGroup(
            adminpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(adminpanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(adminpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(adminpanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jDateChooser5, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(adminpanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(idcorrecteurField, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(validerfiche)
                    .addComponent(datecorrectionLabel)
                    .addComponent(idcorrecteurLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        adminpanelLayout.setVerticalGroup(
            adminpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(adminpanelLayout.createSequentialGroup()
                .addComponent(datecorrectionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jDateChooser5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(idcorrecteurLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(idcorrecteurField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addComponent(validerfiche)
                .addContainerGap())
        );

        saveButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 5, true), "A Sauvegarder", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14), new java.awt.Color(204, 0, 0))); // NOI18N
        saveButton.setRequestFocusEnabled(false);
        saveButton.setRolloverEnabled(false);
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveFicheA(evt);
            }
        });

        refreshButton.setBackground(new java.awt.Color(255, 255, 255));
        refreshButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/refresh.jpg"))); // NOI18N
        refreshButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true), "Rafraichir", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        refreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshA(evt);
            }
        });

        javax.swing.GroupLayout CommandesLayout = new javax.swing.GroupLayout(Commandes);
        Commandes.setLayout(CommandesLayout);
        CommandesLayout.setHorizontalGroup(
            CommandesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CommandesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(CommandesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(adminpanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(CommandesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(effacerButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(refreshButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(saveButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(nouvelFicheButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        CommandesLayout.setVerticalGroup(
            CommandesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CommandesLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(nouvelFicheButton, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(refreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(effacerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addComponent(adminpanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout ficheAcreerJIFLayout = new javax.swing.GroupLayout(ficheAcreerJIF.getContentPane());
        ficheAcreerJIF.getContentPane().setLayout(ficheAcreerJIFLayout);
        ficheAcreerJIFLayout.setHorizontalGroup(
            ficheAcreerJIFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ficheAcreerJIFLayout.createSequentialGroup()
                .addComponent(Formulaire, javax.swing.GroupLayout.PREFERRED_SIZE, 723, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Commandes, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );
        ficheAcreerJIFLayout.setVerticalGroup(
            ficheAcreerJIFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ficheAcreerJIFLayout.createSequentialGroup()
                .addGroup(ficheAcreerJIFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Formulaire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(ficheAcreerJIFLayout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(Commandes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        ficheAcreerJIF.setBounds(10, 10, 930, 560);
        desktop.add(ficheAcreerJIF, javax.swing.JLayeredPane.DEFAULT_LAYER);

        donneesTablesCreation.setBackground(new java.awt.Color(204, 255, 204));
        donneesTablesCreation.setClosable(true);
        donneesTablesCreation.setIconifiable(true);
        donneesTablesCreation.setResizable(true);
        donneesTablesCreation.setTitle("DONNEES CEHA");
        donneesTablesCreation.setOpaque(true);
        donneesTablesCreation.setVisible(true);

        masterscrollpane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        masterscrollpane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        masterTable.setGridColor(new java.awt.Color(0, 0, 0));

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
        columnBinding.setColumnName("Id");
        columnBinding.setColumnClass(Integer.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${imagefilename}"));
        columnBinding.setColumnName("Imagefilename");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${auteur}"));
        columnBinding.setColumnName("Auteur");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
        columnBinding.setColumnName("Date");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${datecorrection}"));
        columnBinding.setColumnName("Datecorrection");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${datedonation}"));
        columnBinding.setColumnName("Datedonation");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${datetexte}"));
        columnBinding.setColumnName("Datetexte");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${dimension}"));
        columnBinding.setColumnName("Dimension");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${droitsrepro}"));
        columnBinding.setColumnName("Droitsrepro");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fond}"));
        columnBinding.setColumnName("Fond");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${idcorrecteur}"));
        columnBinding.setColumnName("Idcorrecteur");
        columnBinding.setColumnClass(Integer.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${lienfichier}"));
        columnBinding.setColumnName("Lienfichier");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${lienimage}"));
        columnBinding.setColumnName("Lienimage");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${localisation}"));
        columnBinding.setColumnName("Localisation");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${resume}"));
        columnBinding.setColumnName("Resume");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${source}"));
        columnBinding.setColumnName("Source");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${titre}"));
        columnBinding.setColumnName("Titre");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${typedocument}"));
        columnBinding.setColumnName("Typedocument");
        columnBinding.setColumnClass(String.class);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        masterTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                masterTableMouseClicked(evt);
            }
        });
        masterscrollpane.setViewportView(masterTable);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Choix des colonnes à afficher :");

        raz.setFont(new java.awt.Font("Tahoma", 1, 12));
        raz.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/gomme.gif"))); // NOI18N
        raz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                razActionPerformed(evt);
            }
        });

        idC.setBackground(new java.awt.Color(255, 204, 102));
        idC.setFont(new java.awt.Font("Tahoma", 1, 12));
        idC.setText("Id");
        idC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idA(evt);
            }
        });

        sourceC.setBackground(new java.awt.Color(255, 204, 102));
        sourceC.setFont(new java.awt.Font("Tahoma", 1, 12));
        sourceC.setText("source");
        sourceC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sourceA(evt);
            }
        });

        typedocC.setBackground(new java.awt.Color(255, 204, 102));
        typedocC.setFont(new java.awt.Font("Tahoma", 1, 12));
        typedocC.setText("type document");
        typedocC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                typedocA(evt);
            }
        });

        jLabel2.setText("remise à zéro");

        javax.swing.GroupLayout donneesTablesCreationLayout = new javax.swing.GroupLayout(donneesTablesCreation.getContentPane());
        donneesTablesCreation.getContentPane().setLayout(donneesTablesCreationLayout);
        donneesTablesCreationLayout.setHorizontalGroup(
            donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(donneesTablesCreationLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(masterscrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 921, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(donneesTablesCreationLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addGroup(donneesTablesCreationLayout.createSequentialGroup()
                                .addComponent(idC)
                                .addGap(18, 18, 18)
                                .addComponent(sourceC)
                                .addGap(15, 15, 15)
                                .addComponent(typedocC)
                                .addGap(588, 588, 588)
                                .addComponent(raz)))))
                .addContainerGap())
        );
        donneesTablesCreationLayout.setVerticalGroup(
            donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(donneesTablesCreationLayout.createSequentialGroup()
                .addGroup(donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(donneesTablesCreationLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(donneesTablesCreationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(idC)
                            .addComponent(sourceC)
                            .addComponent(typedocC)))
                    .addComponent(raz, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(masterscrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
                .addContainerGap())
        );

        donneesTablesCreation.setBounds(20, 10, 950, 440);
        desktop.add(donneesTablesCreation, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menubar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        menubar1.setFont(new java.awt.Font("Times New Roman", 1, 14));

        mainmenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/petitlogoCEHA.jpg"))); // NOI18N
        mainmenu.setText("CEHA");

        quitte.setText("Quitter");
        quitte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitteActionPerformed(evt);
            }
        });
        mainmenu.add(quitte);

        menubar1.add(mainmenu);

        setJMenuBar(menubar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 1021, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 934, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void quitteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitteActionPerformed
        System.exit(0);
}//GEN-LAST:event_quitteActionPerformed

    private void parcourirVignetteA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parcourirVignetteA

        String ressourceStrRef = main.getRepvignette().getText();
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new File(ressourceStrRef));
        chooser.changeToParentDirectory();
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            lienvignette1.setText(chooser.getSelectedFile().getAbsolutePath());
            vignette1.setIcon(new javax.swing.ImageIcon(chooser.getSelectedFile().getAbsolutePath()));

        }
}//GEN-LAST:event_parcourirVignetteA

    private void parcourirFichierA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parcourirFichierA

        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            lienFichierField.setText(chooser.getSelectedFile().getAbsolutePath());
        }
}//GEN-LAST:event_parcourirFichierA

    private void parcourirLienImageA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parcourirLienImageA
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            lienimageField.setText(chooser.getSelectedFile().getAbsolutePath());
        }
}//GEN-LAST:event_parcourirLienImageA

    private void nouvelFicheA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nouvelFicheA

        ficheEnable(true);
        ceha.Fiche f = new ceha.Fiche();
        entityManager.persist(f);
        list.add(f);
        int row = list.size() - 1;
        masterTable.setRowSelectionInterval(row, row);
        masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
        nouvelFicheButton.setIcon(null);
}//GEN-LAST:event_nouvelFicheA

    private void deleteFicheA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteFicheA
        new OkCancelDialog("Certain d'effacer ?", this, true).setVisible(true);
        if (OkCancelDialog.RET_OK == 1) {
             ficheEnable(false);
            int[] selected = masterTable.getSelectedRows();
            List<ceha.Fiche> toRemove = new ArrayList<ceha.Fiche>(selected.length);


            for (int idx = 0; idx
                    < selected.length; idx++) {
                ceha.Fiche f = list.get(masterTable.convertRowIndexToModel(selected[idx]));
                toRemove.add(f);
                entityManager.remove(f);
            }
            list.removeAll(toRemove);
        }
}//GEN-LAST:event_deleteFicheA

    private void saveFicheA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveFicheA
        if (titreField1.getText().equals("")) {
            this.message = "Titre obligatoire !";
            new OkDialog(this, true).setVisible(true);
        } else {
            try {
                entityManager.getTransaction().commit();
                entityManager.getTransaction().begin();
            } catch (RollbackException rex) {
                rex.printStackTrace();
                entityManager.getTransaction().begin();
                List<ceha.Fiche> merged = new ArrayList<ceha.Fiche>(list.size());
                for (ceha.Fiche f : list) {
                    merged.add(entityManager.merge(f));
                }
                list.clear();
                list.addAll(merged);
            }

            lienvignette1.setText("");
            vignette1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/fondlogoCEHA.jpg")));
        }
}//GEN-LAST:event_saveFicheA

    private void razActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_razActionPerformed
}//GEN-LAST:event_razActionPerformed

    private void idA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idA

        TableColumn column = masterTable.getColumnModel().getColumn(0);
        detruireColonne(column);
}//GEN-LAST:event_idA

    private void sourceA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceA
        TableColumn column = masterTable.getColumnModel().getColumn(1);
        detruireColonne(column);
}//GEN-LAST:event_sourceA

    private void typedocA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_typedocA
        TableColumn column = masterTable.getColumnModel().getColumn(2);
        detruireColonne(column);
}//GEN-LAST:event_typedocA

    private void masterTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_masterTableMouseClicked
        int id = masterTable.getSelectedRow();
        String filename = (String) masterTable.getValueAt(id, 1);
        System.out.println(id);

//        fiche.getVignette1().setIcon(new javax.swing.ImageIcon(filename));
//        System.out.println(id);
//        String lienfichier = (String) masterTable.getValueAt(id, 8);
//        lienFichierButton.setText(lienfichier);
        if (filename == null) {
            vignette1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/fondlogoCEHA.jpg")));
        } else {
            vignette1.setIcon(new javax.swing.ImageIcon(filename));
        }

    }//GEN-LAST:event_masterTableMouseClicked

    private void refreshA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshA
        entityManager.getTransaction().rollback();
        entityManager.getTransaction().begin();
        java.util.Collection data = query.getResultList();
        for (Object entity : data) {
            entityManager.refresh(entity);
        }
        list.clear();
        list.addAll(data);
    }//GEN-LAST:event_refreshA
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel CadreVignette1;
    private javax.swing.JPanel Commandes;
    private javax.swing.JPanel Formulaire;
    private javax.swing.JPanel adminpanel;
    private javax.swing.JTextField auteurField1;
    private javax.swing.JLabel auteurLabel1;
    private javax.swing.JLabel dateLabel1;
    private javax.swing.JLabel datecorrectionLabel;
    private javax.swing.JLabel datedonationLabel1;
    private javax.swing.JLabel datetexteLabel2;
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JTextField dimensionField1;
    private javax.swing.JLabel dimensionLabel1;
    private javax.swing.JInternalFrame donneesTablesCreation;
    private javax.swing.JComboBox droitsreproCombo1;
    private javax.swing.JLabel droitsreproLabel1;
    private javax.swing.JButton effacerButton;
    private javax.persistence.EntityManager entityManager;
    private javax.swing.JInternalFrame ficheAcreerJIF;
    private javax.swing.JButton fichierButton;
    private javax.swing.JTextField fondField1;
    private javax.swing.JLabel fondLabel1;
    private javax.swing.JPanel historicpanel1;
    private javax.swing.JCheckBox idC;
    private javax.swing.JTextField idcorrecteurField;
    private javax.swing.JLabel idcorrecteurLabel;
    private javax.swing.JButton imageButton;
    private javax.swing.JLabel imagefilenameLabel1;
    private com.toedter.calendar.JDateChooser jDateChooser3;
    private com.toedter.calendar.JDateChooser jDateChooser4;
    private com.toedter.calendar.JDateChooser jDateChooser5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextField lienFichierField;
    private javax.swing.JLabel lienfichierLabel1;
    private javax.swing.JTextField lienimageField;
    private javax.swing.JLabel lienimageLabel1;
    private javax.swing.JTextField lienvignette1;
    private java.util.List<ceha.Fiche> list;
    private javax.swing.JTextField localisationField1;
    private javax.swing.JLabel localisationLabel1;
    private javax.swing.JMenu mainmenu;
    private javax.swing.JTable masterTable;
    private javax.swing.JScrollPane masterscrollpane;
    private javax.swing.JMenuBar menubar1;
    private javax.swing.JButton nouvelFicheButton;
    private javax.swing.JButton parcourirvignette;
    private javax.persistence.Query query;
    private javax.swing.JMenuItem quitte;
    private javax.swing.JButton raz;
    private javax.swing.JButton refreshButton;
    private javax.swing.JTextArea resumeArea1;
    private javax.swing.JLabel resumeLabel1;
    private javax.swing.JButton saveButton;
    private javax.swing.JComboBox siecleCombo1;
    private javax.swing.JCheckBox sourceC;
    private javax.swing.JLabel sourceLabel1;
    private javax.swing.JComboBox sourcecombo1;
    private javax.swing.JTextArea titreField1;
    private javax.swing.JLabel titreLabel1;
    private javax.swing.JCheckBox typedocC;
    private javax.swing.JComboBox typedocCombo1;
    private javax.swing.JLabel typedocumentLabel2;
    private javax.swing.JButton validerfiche;
    private javax.swing.JLabel vignette1;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
